<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="活动时间">
              <a-range-picker format="YYYY-MM-DD" :placeholder="['开始时间', '结束时间']" @change="onDateCustChange"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="活动状态">
              <a-select :default-value="null" v-model="queryParam.activeStatus" placeholder="全部" @change="searchQuery">
                <a-select-option :value="null">
                  全部
                </a-select-option>
                <a-select-option :value="1">
                  未开始
                </a-select-option>
                <a-select-option :value="2">
                  进行中
                </a-select-option>
                <a-select-option :value="3">
                  已结束
                </a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
    </div>

    <!-- table区域-begin -->
    <div>
      <a-table ref="table"
               size="middle"
               :scroll="{x:true}"
               bordered
               rowKey="id"
               :columns="columns"
               :dataSource="dataSource"
               :pagination="ipagination"
               :loading="loading"
               class="j-table-force-wrap"
               @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="activeStatus" slot-scope="text, record">
          <a-tag color="orange" v-if="record.activeStatus==1">未开始</a-tag>
          <a-tag color="green" v-if="record.activeStatus==2">进行中</a-tag>
          <a-tag color="red" v-if="record.activeStatus==3">已结束</a-tag>
        </template>

        <span slot="action" slot-scope="text, record">
          <!-- <a @click="handleCopy(record)">复制</a>
          <a-divider type="vertical" /> -->
          <a @click="handleEdit(record)">编辑</a>
          <a-divider type="vertical"/>
          <a @click="handInfo(record)">商品设置</a>
          <a-divider type="vertical"/>
          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
            <a>删除</a>
          </a-popconfirm>

        </span>

      </a-table>
    </div>

    <msms-scene-modal ref="modalForm" @ok="modalFormOk"></msms-scene-modal>
  </a-card>
</template>

<script>

import '@/assets/less/TableExpand.less'
import {mixinDevice} from '@/utils/mixin'
import {JeecgListMixin} from '@/mixins/JeecgListMixin'
import MsmsSceneModal from './modules/MsmsSceneModal'

export default {
  name: 'MsmsSceneList',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    MsmsSceneModal
  },
  data() {
    return {
      description: '秒杀场次管理页面',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: "center",
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '秒杀标题',
          align: "center",
          dataIndex: 'title'
        },
        {
          title: '开始时间',
          align: "center",
          dataIndex: 'startTime'
        },
        {
          title: '结束时间',
          align: "center",
          dataIndex: 'endTime'
        },
        {
          title: '活动状态',
          align: "center",
          dataIndex: 'isActive',
          scopedSlots: {customRender: 'activeStatus'}
        },
        {
          title: '是否展示',
          align: "center",
          dataIndex: 'isDisplay',
          customRender: function (text) {
            return text == 1 ? '是' : '否'
          }
        },

        {
          title: '操作',
          dataIndex: 'action',
          align: "center",
          fixed: "right",
          width: 200,
          scopedSlots: {customRender: 'action'}
        }
      ],
      url: {
        list: "/mallPlus/msmsScene/list",
        delete: "/mallPlus/msmsScene/delete",
        deleteBatch: "/mallPlus/msmsScene/deleteBatch",
        exportXlsUrl: "/mallPlus/msmsScene/exportXls",
        importExcelUrl: "mallPlus/msmsScene/importExcel",

      },
      dictOptions: {},
    }
  },
  created() {
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
  },
  methods: {
    handleCopy(record) {

    },
    handInfo(record) {
      this.$router.push({path: '/marketing/ms/MsmsGoodList', query: {id: record.id}})
    },
    onDateCustChange: function (value, dateString) {
      this.queryParam.endTime_begin = dateString[0]
      this.queryParam.startTime_end = dateString[1]
    },
    initDictConfig() {
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
